<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态加载JS</title>
</head>
<body>

<div id="test"></div>

<script>
    function loadJs(url ,cb) {
      var script = document.createElement('script'),
        fn = cb || function () {};
      script.type = 'text/javascript'

      // IE
      if(script.readyState) {
        script.onreadystatechange = function () {
          if(script.readyState == 'loaded' || script.readyState == 'complete') {
            script.onreadystatechange = null;
            fn();
          }
        }
      }else{
        // else browser
        script.onload = function () {
          fn();
        }
      }
      script.src = url;
      document.getElementsByTagName('head')[0].appendChild(script)
    }

    window.onload = function () {
      loadJs('https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js', function () {
        $("#test").text('修改完成')
      })
    }
</script>

</body>
</html>
